Turn on premultiplied alpha (and alpha) by default #5917
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #5891 (also #5634, #5890, closed because the change was intentional, but it seems like the change is confusing for users.)
Changes
High level
alpha
to true againpremultipliedAlpha
to true to fix weird the weird blending issues (WebGL background & clear odd behaviour #5195, Semi-transparent objects in WebGL mode make the background behind them transparent #5451) that caused us to remove alpha beforeNotes
MULTIPLY
also multiplies the alpha channel instead of 2D mode, where it blends with white before multiplying.LIGHTEST
andDARKEST
unfortunately work less well with premultiplied alpha, as 2D mode takes the max/min of the un-premultiplied channel values. This is a downgrade from beforeSCREEN
,REMOVE
, andEXCLUSION
handle semitransparency better nowgl.pixelStorei(gl.UNPACK_PREMULTIPLIED_ALPHA, true)
, because the other color inputs to shaders are unmultiplied. (If we choose to keep our shaders the same and instead change our color inputs to them, we would need to turn this setting on to match.)Live test files
Screenshots of the change
Antialiasing on clear backgrounds
Blend modes on a clear background
In each screenshot, the left column is 2D mode, and the right column is WebGL mode.
Semitransparent white
Semitransparent black
PR Checklist
npm run lint
passes